# -*- encoding: utf-8 -*-

CPS_FILTER_REPORT_CONFIG = {
    'real_time_report': True,
    'group_by': '_chn.keyword',
    'target_event_id': ['recharge', 'withdraw', 'platform_reward', 'cp_game', 'cp_lottery'],
    'values': [
        {
            "value_id": "recharge_amount",
            "target_value": "recharge_price",
            "value_name": "充值金额",
            "filter": [
                {'term': {'_event_id': 'recharge'}},
            ],
        },
        {
            "value_id": "recharge_user",
            "target_value": "_user_id",
            "value_name": "充值账号",
            "filter": [
                {'term': {'_event_id': 'recharge'}},
            ],
            "operation": "cardinality",
        },
        {
            "value_id": "withdraw_amount",
            "target_value": "withdraw_price",
            "value_name": "提现金额",
            "filter": [
                {'term': {'_event_id': 'withdraw'}},
            ],
        },
        {
            "value_id": "lottery_bet_amount",
            "target_value": "cp_lottery_price",
            "value_name": "购彩流水",
            "filter": [
                {'terms': {'_event_id': ['cp_lottery']}},
                {'term': {'cp_lottery_refund': 0}}
            ],
            "value_type": "float"
        },
        {
            "value_id": "lottery_win_amount",
            "target_value": ["cp_lottery_bonus", "+", "cp_lottery_win"],
            "value_name": "购彩中奖",
            "filter": [
                {'terms': {'_event_id': ['cp_lottery']}},
            ],
            "value_type": "float"
        },
        {
            "value_id": "dwc_bet_amount",
            "target_value": ["cp_game_price"],
            "value_name": "总电玩城流水",
            "filter": [
                {'terms': {'_event_id': ['cp_game']}},
            ],
            "value_type": "float"
        },
        {
            "value_id": "dwc_win_amount",
            "target_value": ["cp_game_win"],
            "value_name": "总电玩城中奖",
            "filter": [
                {'terms': {'_event_id': ['cp_game']}},
            ],
            "value_type": "float"
        },
        {
            "value_id": "platform_reward_amount",
            "target_value": "platform_reward_reward_amount",
            "value_name": "活动奖励",
            "filter": [
                {'term': {'_event_id': 'platform_reward'}},
            ],
            "value_type": "float"
        },
        {
            "value_id": "total_profit",
            "value_name": "利润",
            "value_expr": "lottery_bet_amount + dwc_bet_amount - lottery_win_amount - dwc_win_amount",
            "value_type": "float"
        }
    ]
}
